import { ProjectConfig } from '../types/config';
import type { State, UserInfo } from '/@/types';
import { loadCookie, loadStorage } from '/@/utils/cache';
import {
  ACCESS_TOKEN,
  LOGIN_STATUS,
  USER_INFO,
  PROJECT_SETTING,
  SCOPE_NUMBER,
  MY_INTENTION,
} from '/@/utils/constants';

const defaultProjectSetting: ProjectConfig = {
  showFaith: 1,
  showFather: 1,
  showMary: 1,
  showGlory: 1,
  showQueen: 1,
  showSong: true,
  onlyShowBody: false,
  rosarySelect: ['joyful', 'luminous', 'sorrowful', 'glorious'],
};

const state: State = {
  loginStatus: Number(loadCookie(LOGIN_STATUS, '0')),
  // loginStatus: 0,
  accessToken: loadStorage(ACCESS_TOKEN, ''),
  userInfo: loadStorage(USER_INFO, {
    openid: '',
    nickname: '',
    headimgurl: '',
  }) as UserInfo,
  code: '',
  projectSetting: loadStorage(PROJECT_SETTING, defaultProjectSetting) as ProjectConfig,
  scopeNumber: Number(loadCookie(SCOPE_NUMBER, '0')),
  startDate: {},
  intention: {},
  myIntention: loadStorage(MY_INTENTION, '') as string,
};

export default state;
